﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BabyFood.Entities;
using BabyFood.Data;

public partial class Controls_ControlBaBauCont : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HienThiBaBau01();
            HienThiBaBau02();
            HienThiBaBau03();
            HienThiBaBau01all();
            HienThiBaBau02all();
            HienThiBaBau03all();
        }
    }

    private void HienThiBaBau01()
    {
        int TotalRows = 0;
        TList<TinTuc> TList_TinTuc = DataRepository.TinTucProvider.GetPaged("IdSubTinTuc=7 and Tinnong=1", "NgayCapNhat DESC", 0, 1, out TotalRows);
        dlBaBau01.DataSource = TList_TinTuc;
        dlBaBau01.DataBind();
    }

    private void HienThiBaBau01all()
    {
        int TotalRows = 0;
        TList<TinTuc> TList_TinTuc = DataRepository.TinTucProvider.GetPaged("IdSubTinTuc=7 and Tinnong=1", "NgayCapNhat DESC", 0, 3, out TotalRows);
        dlBaBau01all.DataSource = TList_TinTuc;
        dlBaBau01all.DataBind();
    }

    private void HienThiBaBau02()
    {
        int TotalRows = 0;
        TList<TinTuc> TList_TinTuc = DataRepository.TinTucProvider.GetPaged("IdSubTinTuc=8 and Tinnong=1", "NgayCapNhat DESC", 0, 1, out TotalRows);
        dlBaBau02.DataSource = TList_TinTuc;
        dlBaBau02.DataBind();
    }

    private void HienThiBaBau02all()
    {
        int TotalRows = 0;
        TList<TinTuc> TList_TinTuc = DataRepository.TinTucProvider.GetPaged("IdSubTinTuc=8 and Tinnong=1", "NgayCapNhat DESC", 0, 3, out TotalRows);
        dlBaBau02all.DataSource = TList_TinTuc;
        dlBaBau02all.DataBind();
    }

    private void HienThiBaBau03()
    {
        int TotalRows = 0;
        TList<TinTuc> TList_TinTuc = DataRepository.TinTucProvider.GetPaged("IdSubTinTuc=9 and Tinnong=1", "NgayCapNhat DESC", 0, 1, out TotalRows);
        dlBaBau03.DataSource = TList_TinTuc;
        dlBaBau03.DataBind();
    }

    private void HienThiBaBau03all()
    {
        int TotalRows = 0;
        TList<TinTuc> TList_TinTuc = DataRepository.TinTucProvider.GetPaged("IdSubTinTuc=9 and Tinnong=1", "NgayCapNhat DESC", 0, 3, out TotalRows);
        dlBaBau03all.DataSource = TList_TinTuc;
        dlBaBau03all.DataBind();
    }

    /// <summary>
    /// Handles ItemDataBound, Binds ExchangesTo to the Child DataList
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void dlFromTrades_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {

            DataListItem parentList = e.Item;
            HiddenField lit_Name = (HiddenField)parentList.FindControl("H_CatalogId");
            string i = (lit_Name.Value).ToString();
            int j = Convert.ToInt32(i);
            int TotalRows = 0;
            //TList<Comment> TList_TinTucs = DataRepository.CommentProvider.GetPaged("IdTinTuc = " + j, "", 0, 0, out TotalRows);
            //// Retrieve the Parent List

            //Label label1 = (Label)parentList.FindControl("lblComment");
            //label1.Text = TotalRows.ToString();

            //int ChiaSe = 0;
            //TList<Thich> TList_Thich = DataRepository.ThichProvider.GetPaged("IdTinTuc = " + j, "", 0, 0, out ChiaSe);
            //// Retrieve the Parent List
            //Label chiaselb = (Label)parentList.FindControl("lblChiaSe");
            //if (chiaselb != null)
            //    chiaselb.Text = ChiaSe.ToString();
        }
    }

    public string GetLienKet()
    {
        return Common.sPathUpLienKet;
    }

    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }
}